package com.elephant.core.classloader;

/**
 * @Author: hai
 * @Date: 2019/1/31 14:15
 */
public class Test {

    /**
     * 看sun.misc.Launcher,它是一个java虚拟机的入口应用。
     *
     * 好了，自此我们已经知道了BootstrapClassLoader、ExtClassLoader、AppClassLoader实际是查阅相应的环境属性
     * sun.boot.class.path
     * java.ext.dirs
     * java.class.path
     * 来加载资源文件的。
     * @param args
     */
    public static void main(String[] args) {

        String property = System.getProperty("sun.boot.class.path");
        String[] arr = property.split(";");

        for (int i = 0; i < arr.length ; i++) {

            System.out.println(arr[i]);
        }

        System.out.println("------------------");
        System.out.println(System.getProperty("java.ext.dirs"));

        System.out.println("------------------");
        String property1 = System.getProperty("java.class.path");
        String[] arr1 = property1.split(";");
        for (int i = 0; i < arr1.length ; i++) {
            System.out.println(arr1[i]);
        }

        ClassLoader c1 = Test.class.getClassLoader();
        System.out.println(c1.toString());

        System.out.println(int.class.getClassLoader());

        System.out.println("ClassLoader is:" + c1.toString());
        System.out.println("ClassLoader\'s parent is:" + c1.getParent().toString());
        System.out.println("ClassLoader\'s grand father is:" + c1.getParent().getParent());

    }

    public void say(){
        System.out.println("test classloader");
    }
}
